var util = require('../../../../../utils/util.js');
var api = require('../../../../../config/api.js');

var app = getApp();

Page({
  data: {
    type: 0,
    goodslist: [],
    page: 1,
    size: 10,
    memberUserid: ''
  },


  getCollectList: function () {
    let that = this;
    util.request(api.Fenxiaotuiguangshangpin, {
      page: that.data.page,
      size: that.data.size
    }).then(function (res) {
      if (res.result == 1) {
        if (res.data.result.length > 0) {
          that.setData({
            goodslist: that.data.goodslist.concat(res.data.result),
            page: that.data.page + 1
          });
        } else {
          wx.showToast({
            title: '已经被您看完了!',
            icon: 'none',
            duration: 2000
          });
          return false;
        }
      }
    });
  },
  //点击推广商品
  goGoods: function (event) {
    let goodsid = event.currentTarget.dataset.goodsid;
    wx.navigateTo({
      url: "/pages/goods/goods?id="+goodsid
    });
  },
  onLoad: function (options) {

  },
  onReachBottom() {
    this.getCollectList();
  },
  onReady: function () {

  },
  onShow: function () {
    let that = this;
    if (that.data.goodslist.length == 0) {
      this.getCollectList();
    }
  },
  onHide: function () {
    // 页面隐藏

  },
  onUnload: function () {
    // 页面关闭
  },

})